Skip to content

Fastapi + Gunicorn example in README#812

Merged
csmarchbanks merged 3 commits into
prometheus:masterfrom
ashirviskas:feature/readme_fastapi_gunicorn
Apr 18, 2023
Merged

Fastapi + Gunicorn example in README#812
csmarchbanks merged 3 commits into
prometheus:masterfrom
ashirviskas:feature/readme_fastapi_gunicorn

Conversation

@ashirviskas

@ashirviskas ashirviskas commented May 18, 2022

Copy link
Copy Markdown
Contributor

Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: #810

Signed-off-by: Matas Minelga minematas@gmail.com

Comment thread README.md Outdated
def make_metrics_app():
registry = CollectorRegistry()
multiprocess.MultiProcessCollector(registry)
return prometheus_client.make_asgi_app(registry=registry)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashirviskas should be based on the import

return make_asgi_app(registry=registry)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be late, but I just fixed it

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good to me with a small nit. In addition, the second commit needs to be signed off.

Comment thread README.md Outdated

metrics_app = make_metrics_app()
app.mount("/metrics", metrics_app))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: extra newline here.

Comment thread README.md Outdated


metrics_app = make_metrics_app()
app.mount("/metrics", metrics_app))

@JoshChristie JoshChristie Nov 11, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove double ) at the end of line

@jgould22

Copy link
Copy Markdown

I am still learning a bit when it comes to pythons async implementation but should it not be noted in the Multiprocess portion that multiprocess mode uses blocking io calls (to a memory mapped file so it is quick, but will still blocks the event loop)?

@gal-leib

gal-leib commented Feb 9, 2023

Copy link
Copy Markdown

I know this isn't merged yet, but is it good practice?
Since in the documentation it says the Registry should be created in the context of a request, but here it will be created at the startup of the process no?

@OliverFarren

Copy link
Copy Markdown

It's the 11 month anniversary of this PR, are we still deliberating or could this be merged in?

As per the motive of the original #810, having this in the README.md would have saved significant time.

@csmarchbanks

csmarchbanks commented Apr 18, 2023

Copy link
Copy Markdown
Member

I cannot merge this without the DCO being signed for all commits.

I know this isn't merged yet, but is it good practice?
Since in the documentation it says the Registry should be created in the context of a request, but here it will be created at the startup of the process no?

As the readme mentions, that is best practice to avoid metrics registering themselves with the multiprocess registry. Since the registry is only created inside of the create app function I think this approach is correct.

@ashirviskas

ashirviskas commented Apr 18, 2023

Copy link
Copy Markdown
Contributor Author

Whats the easiest way I could resign all the commits?

EDIT: Amended the commit messages, just no idea how to trigger DCO to rerun.

@ashirviskas ashirviskas force-pushed the feature/readme_fastapi_gunicorn branch from 9a7198a to b1c9ce5 Compare April 18, 2023 14:10
Also provided additional multiprocessing instructions for FastAPI + Gunicorn setup with code examples as per this issue: prometheus#810

Signed-off-by: Matas Minelga <minematas@gmail.com>
Signed-off-by: Matas Minelga <minematas@gmail.com>
Removed extra characters

Signed-off-by: Matas Minelga <minematas@gmail.com>
@ashirviskas ashirviskas force-pushed the feature/readme_fastapi_gunicorn branch from b1c9ce5 to c4af65e Compare April 18, 2023 14:20

@csmarchbanks csmarchbanks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it ran when you force pushed (as it should). Thanks!

@csmarchbanks csmarchbanks merged commit 39a62af into prometheus:master Apr 18, 2023
@OliverFarren

Copy link
Copy Markdown

Wow! Thanks everyone for sorting today and for creating the additional PR in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants